<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>splice使用技巧</title>
</head>
<body>
    <script>
        var arr=[1,2,3];//1
        var targetindex = 1;//2
        var currentindex = 0;//3
        // splice 返回被删除的数据
        arr.splice(targetindex,1,arr.splice(currentindex,1,arr[targetindex])[0]) //4
    </script>
</body>
</html>